﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;

namespace Quellenverwaltung.Data.Source
{
    public abstract class Source
    {

        [XmlElement(ElementName = "SourceType", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public String SourceType { get; set; }
        [XmlElement(ElementName = "Tag", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public String Tag { get; set; }
        [XmlElement(ElementName = "Title", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public String Title { get; set; }
        [XmlElement(ElementName = "Year", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public String Year { get; set; }
        [XmlElement(ElementName = "Author", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public Authors Author { get; set; }
        [XmlElement(ElementName = "RefOrder", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public String RefOrder { get; set; }
        [XmlElement(ElementName = "StandardNumber", Namespace = "http://schemas.microsoft.com/office/word/2004/10/bibliography")]
        public String StandardNumber { get; set; }


        [XmlIgnore]
        public String AuthorNamesAsString
        {
            get
            {
                if (Author != null && Author.Author != null)
                    return Author.Author.NameListAsString;
                else
                    return "";
            }
            set
            {
                if (value != null)
                {
                    if (Author == null)
                    {
                        Author = new Authors();
                    }
                    if (Author.Author == null)
                    {
                        Author.Author = new Author();
                    }

                    Author.Author.NameListAsString = value;
                }
            }
        }

        [XmlIgnore]
        public String AuthorCorporateAsString
        {
            get
            {
                if (Author == null)
                {
                    Author = new Authors();
                }
                if (Author.Author == null)
                {
                    Author.Author = new Author();
                }

                return Author.Author.Corporate;
            }
            set
            {
                if (value != null)
                {
                    if (Author == null)
                    {
                        Author = new Authors();
                    }
                    if (Author.Author == null)
                    {
                        Author.Author = new Author();
                    }

                    Author.Author.Corporate = value;
                }
            }
        }

        [XmlIgnore]
        public String EditorNamesAsString
        {
            get
            {
                if (Author == null)
                {
                    Author = new Authors();
                }
                if (Author.Editor == null)
                {
                    Author.Editor = new Author();
                }

                if (Author != null && Author.Editor != null)
                    return Author.Editor.NameListAsString;
                else
                    return "";
            }
            set
            {
                if (value != null)
                {
                    if (Author == null)
                    {
                        Author = new Authors();
                    }
                    if (Author.Editor == null)
                    {
                        Author.Editor = new Author();
                    }

                    Author.Editor.NameListAsString = value;
                }
            }
        }
        [XmlIgnore]
        public String EditorCorporateAsString
        {
            get
            {
                if (Author == null)
                {
                    Author = new Authors();
                }
                if (Author.Editor == null)
                {
                    Author.Editor = new Author();
                }

                return Author.Editor.Corporate;
            }
            set
            {
                if (value != null)
                {
                    if (Author == null)
                    {
                        Author = new Authors();
                    }
                    if (Author.Editor == null)
                    {
                        Author.Editor = new Author();
                    }

                    Author.Editor.Corporate = value;
                }
            }
        }

        [XmlIgnore]
        public String TranslatorNamesAsString
        {
            get
            {
                if (Author == null)
                {
                    Author = new Authors();
                }
                if (Author.Translator == null)
                {
                    Author.Translator = new Author();
                }

                if (Author != null && Author.Translator != null)
                    return Author.Translator.NameListAsString;
                else
                    return "";
            }
            set
            {
                if (value != null)
                {
                    if (Author == null)
                    {
                        Author = new Authors();
                    }
                    if (Author.Translator == null)
                    {
                        Author.Translator = new Author();
                    }

                    Author.Translator.NameListAsString = value;
                }
            }
        }

        [XmlIgnore]
        public String TranslatorCorporateAsString
        {
            get
            {
                if (Author == null)
                {
                    Author = new Authors();
                }
                if (Author.Translator == null)
                {
                    Author.Translator = new Author();
                }

                return Author.Translator.Corporate;
            }
            set
            {
                if (value != null)
                {
                    if (Author == null)
                    {
                        Author = new Authors();
                    }
                    if (Author.Translator == null)
                    {
                        Author.Translator = new Author();
                    }

                    Author.Translator.Corporate = value;
                }
            }
        }

    }
}
